package cn.ccsu.cecs.bonus.controller;


import cn.ccsu.cecs.bonus.entity.BonusComprehensiveScore;
import cn.ccsu.cecs.bonus.service.IBonusComprehensiveScoreService;
import cn.ccsu.cecs.common.utils.PageUtils;
import cn.ccsu.cecs.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Arrays;
import java.util.Map;

/**
 * <p>
 * 综合成绩表 前端控制器
 * </p>
 *
 * @author ccsu-cecs
 * @since 2022-03-10
 */
@Controller
@RequestMapping("/student/bonus-comprehensive-score")
public class BonusComprehensiveScoreController {
    @Autowired
    private IBonusComprehensiveScoreService bonusComprehensiveScoreService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = bonusComprehensiveScoreService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        BonusComprehensiveScore bonusYear = bonusComprehensiveScoreService.getById(id);

        return R.ok().put("bonusYear", bonusYear);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BonusComprehensiveScore bonusComprehensiveScore) {
        bonusComprehensiveScoreService.save(bonusComprehensiveScore);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BonusComprehensiveScore bonusComprehensiveScore) {
        bonusComprehensiveScoreService.updateById(bonusComprehensiveScore);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids) {
        bonusComprehensiveScoreService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
}
